package com.example.myapplication10.Buttons;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.core.content.res.ResourcesCompat;

import com.example.myapplication10.Utils.DisplayUtil;
import com.example.myapplication10.R;

public class Btn_Add extends LinearLayout {
    String str = "城市管理";
    TextView tvB;
//+"良"+" "+"AQI"+"  ";
    public Btn_Add(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        setOrientation(LinearLayout.VERTICAL);
        LinearLayout btLayout = new LinearLayout(context);
        LayoutParams btLp = new LayoutParams
            (ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT,1);
        btLayout.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.button_mini_style,null));
        tvB = new TextView(context);
        tvB.setText(this.str);
        tvB.setGravity(Gravity.CENTER);
        tvB.setTextSize(DisplayUtil.dip2px(context,6));
        tvB.setTextColor(0xffffffff);
        //   tvB.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.add,0,0,0);
        btLayout.addView(tvB);
        btLayout.setGravity(Gravity.CENTER);
        this.addView(btLayout,btLp);

    }

//    @Subscribe(threadMode = ThreadMode.MAIN)
//    public void messageEventBus(MsgEventAQI event) {
//        tvB.setText(this.str);
////        Weather weather = new Weather();
////        CityInfoDTO cityInfo = new CityInfoDTO();
////        DataDTO data = new DataDTO();
////        YesterdayDTO yesterday = new YesterdayDTO();
////        List<ForecastDTO> forecastArrayList = new ArrayList<>();
//
//
//    }
}

//    public Icon(Context context, @Nullable AttributeSet attrs) {
//        super(context, attrs);
//        setOrientation(LinearLayout.VERTICAL);
//        LinearLayout topLayout = new LinearLayout(context);
//        LinearLayout bottomLayout = new LinearLayout(context);
//        LinearLayout.LayoutParams topLp = new LinearLayout.LayoutParams
//                (ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT,2);
//        LinearLayout.LayoutParams bottomLp = new LinearLayout.LayoutParams
//                (ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT,5);
//        topLayout.setBackground(ResourcesCompat.getDrawable(getResources(),R.drawable.top_style,null));
//        bottomLayout.setBackground(ResourcesCompat.getDrawable(getResources(),R.drawable.buttom_style,null));
//        TextView tvM = new TextView(context);
//        TextView tvD = new TextView(context);
//        Calendar date = Calendar.getInstance();
//        tvM.setText(String.valueOf(date.get(Calendar.MONTH)+1)+"月");
//        tvM.setTextSize(DisplayUtil.dip2px(context,30));
//        tvM.setTextColor(0xffffffff);
//        tvD.setText(String.valueOf(date.get(Calendar.DAY_OF_MONTH)));
//        tvD.setTextSize(DisplayUtil.dip2px(context,70));
//        tvD.setTextColor(0xff000000);
//        this.addView(topLayout,topLp);
//        this.addView(bottomLayout,bottomLp);
//        topLayout.addView(tvM);
//        bottomLayout.addView(tvD);
//        topLayout.setGravity(Gravity.CENTER);
//        bottomLayout.setGravity(Gravity.CENTER);
//    }